package net.pimpas.web.jsf.components.group;

import javax.faces.context.FacesContext;

import net.pimpas.web.jsf.components.UIComponentPimpasBase;
import net.pimpas.web.jsf.util.ComponentInformation;

public class UIGroup extends UIComponentPimpasBase {

	public static final String COMPONENT_TYPE				= ComponentInformation.COMPONENT_PREFIX_TYPE+".group";
	public static final String COMPONENT_FAMILY				= ComponentInformation.COMPONENT_PREFIX_FAMILY+".group";
	public static final String COMPONENT_RENDER_TYPE		= ComponentInformation.COMPONENT_PREFIX_RENDER+".group";
	
	public static final String DEFAULT_ICON					= "star.png";
	public static final String DEFAULT_STYLE_FILE			= "pimpasGroup.css";
	public static final String DEFAULT_STYLE_CLASS			= "pimpasGroup";
	public static final String DEFAULT_LEGEND_STYLE_CLASS 	= "label";
	public static final String DEFAULT_LABEL_STYLE_CLASS 	= "icon";
	public static final String DEFAULT_TEXT_STYLE_CLASS 	= "text";
	public static final String DEFAULT_CONTENT_STYLE_CLASS 	= "content";
	public static final String CONTENT_ID					= "_content";
	public static final String FIELDSET_ID					= "_fieldset";
	
	private String title;
	private String icon;
	
	@Override
	public Object saveState(FacesContext context) {
		Object[] ob = new Object[3];
		ob[0] = super.saveState(context);
		ob[1] = this.getTitle();
		ob[2] = this.getIcon();
		
		return ob;
	}
	
	@Override
	public void restoreState(FacesContext context, Object state) {
		Object[] ob = (Object[]) state;
		super.restoreState(context, ob[0]);
		this.setTitle((String) ob[1]);
		this.setIcon((String) ob[2]);
	}
	
	@Override
	public String getRendererType() {
		return COMPONENT_RENDER_TYPE;
	}

	@Override
	public String getFamily() {
		return COMPONENT_FAMILY;
	}
	
	@Override
	public boolean getRendersChildren() {
		return true;
	}

	public String getIcon() {
		return icon;
	}

	public void setIcon(String icon) {
		this.icon = icon;
	}

	public String getTitle() {
		return title;
	}

	public void setTitle(String title) {
		this.title = title;
	}
}